#include <iostream>
#include <cstring>
using namespace std;

int table[102][102],m,n;

int check(int i,int j){
	int tmp=0;
	if(table[i-1][j-1]) tmp++;
	if(table[i-1][j]) tmp++;
	if(table[i-1][j+1]) tmp++;
	if(table[i][j-1]) tmp++;
	if(table[i][j+1]) tmp++;
	if(table[i+1][j-1]) tmp++;
	if(table[i+1][j]) tmp++;
	if(table[i+1][j+1]) tmp++;
	return tmp;
}

int main(){
	
	cin >> n >> m;
	
	for(int i=1;i<=n;i++){
		char line[101];
		cin >> line;
		for(int j=1;j<=m;j++){
			if(line[j-1] == '*') table[i][j] = 1;
			else table[i][j] = 0;
		}
	}
	
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(table[i][j] == 1) cout << "*";
			else cout << check(i,j) ;
		}
		cout << endl;
	}
	
}
